# Contributor: omni <omni+alpine@hack.org>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=jc
pkgver=1.25.3
pkgrel=1
pkgdesc="CLI & python library converting output of common tools, file-types & strings to JSON, YAML or dicts"
url="https://kellyjonbrazil.github.io/jc/"
arch="noarch"
license="MIT"
depends="py3-pygments py3-ruamel.yaml py3-xmltodict"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest tzdata"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-pyc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/kellyjonbrazil/jc/archive/refs/tags/v$pkgver.tar.gz
	fix-tests-ip-address.patch
	"

build() {
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	TZ="America/Los_Angeles" .testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl

	install -Dm644 man/"$pkgname".1 "$pkgdir"/usr/share/man/man1/"$pkgname".1
	install -Dm644 -t "$pkgdir"/usr/share/doc/"$pkgname"/ \
		README.md EXAMPLES.md
	cp -r docs "$pkgdir"/usr/share/doc/"$pkgname"/

	install -Dm644 completions/jc_bash_completion.sh \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 completions/jc_zsh_completion.sh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
c832e3d81d5deedc12e9d9017a60ee1348c96d748dd13fadced1447c275518716b02376113fff536889549eb8ea1fc2c04cb078fb74f6476e361fd842fd1d488  jc-1.25.3.tar.gz
6f61c007e697ce7505e09f159fbe5c4da6286f8b59ed5553230e2b31da926a69065efffc7d03cb1e1f4dade825f2ce69660287c33b59f6aaf277def56e43706a  fix-tests-ip-address.patch
"
